package com.arvin.skin.core.utils;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class ClassUtil {
    public static Field getField(Class clazz,String name){
        try {
            Field field = clazz.getDeclaredField(name);
            field.setAccessible(true);
            return field;
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
            return getField(clazz.getSuperclass(),name);
        }
    }

    public static Method getMethod(Class clazz, String name,Class... params){
        try {
            Method method = clazz.getDeclaredMethod(name,params);
            method.setAccessible(true);
            return method;
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
            return getMethod(clazz.getSuperclass(),name);
        }
    }
}
